<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>01.基本列表</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <h2>人员列表</h2>
        <ul>
            <li v-for="(p,index) in persons" key="">
                {{p.name}}--{{p.sex}}--{{p.age}}岁
            </li>
        </ul>

        <h2>汽车信息</h2>
        <ul>
            <!-- 使用v-for便利对象 -->
            <li v-for="(value,key) in cars" :key="key">{{value}}</li>
        </ul>

        <h2>测试遍历字符串</h2>
        <ul>
            <li v-for="(data,index) in str" :key="index">{{data}} -- {{index}}</li>
        </ul>
    </div>

    <script>
        new Vue({
            el: '#root',
            data: {
                persons: [
                    {id: '001', name: '彭于晏', age: 30, sex: '男'},
                    {id: '002', name: '张家辉', age: 40, sex: '男'},
                    {id: '003', name: '潘粤明', age: 45, sex: '男'},
                    {id: '004', name: '张译', age: 43, sex: '男'},
                    {id: '005', name: '殷桃', age: 42, sex: '女'}
                ],
                cars: {
                    name: '奔驰',
                    price: '20W',
                    color: '银色'
                },
                str: 'abcdefgh'
            }
        })
    </script>
</body>
</html>